﻿<script type="text/javascript">
    $(function () {

        function menu_cheak(selector, classname) {
            var $select = $(selector);
            $select.toggleClass(classname).siblings().removeClass(classname);
        }

        $('.nav li').click(function () {//, 'active');
            menu_cheak(this, "active");
        });
        $('.recipes .recipes_menu .menu_main dl dd a').click(function () {
            var $this = $(this);
            menu_cheak(this, "chosed");

            var action = $this.attr("class") == "";
            var $input = $("#" + $this.data("link-input"));
            if (action) {
                $input.val("");
            }
            else {
                var id = $this.data("id");
                $input.val(id);
            }
            $("#num").val("1");
            submit();
            return false;
        });

        $("#pageJumpSure").click(function () {
            var jumpPage = $("#jumpPage").val();

            var num = parseInt(jumpPage);
            if (!isNaN(num)) {
                $("#num").val(num);
                submit();
            }
        });

        $("#pageBreak li a").click(function () {
            var pageNum = $(this).attr("data-num");
            if (pageNum != "undefined" && pageNum != null) {
                $("#num").val(pageNum);
                submit();
            }
            return false;
        });


        function submit() {

            $("#searchForm").submit();
        }

        function accordion_menu(selector, operated, classname) {
            var $select = selector;
            $select.click(function () {

                $(this).parent().toggleClass(operated);
                $(this).next(classname).slideToggle(300);
            })

        }
        accordion_menu($('.recipes .recipes_menu .menu_main dl dt'), 'on', 'dd');


    });

</script>
